From e6e5b8fba0a2747c3d15f96c314d6111d00f4174 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 8 Jul 2010 09:44:46 +0100 Subject: [PATCH] x86/cpufreq: check array index before use ... rather than after. Signed-off-by: Jan Beulich --- xen/arch/x86/acpi/cpufreq/cpufreq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/acpi/cpufreq/cpufreq.c b/xen/arch/x86/acpi/cpufreq/cpufreq.c index a9b1d239a2..d9697ddf32 100644 --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c @@ -210,9 +210,11 @@ static u32 get_cur_val(cpumask_t mask) if (!cpu_isset(cpu, mask)) cpu = first_cpu(mask); - policy = cpufreq_cpu_policy[cpu]; + if (cpu >= NR_CPUS) + return 0; - if (cpu >= NR_CPUS || !policy || !drv_data[policy->cpu]) + policy = cpufreq_cpu_policy[cpu]; + if (!policy || !drv_data[policy->cpu]) return 0; switch (drv_data[policy->cpu]->cpu_feature) { -- 2.30.2